﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Smled
{
    public partial class RandomBrushWizard : Form
    {
        private RandomBrush brush = null;
        private bool ok = false;

        public RandomBrushWizard()
        {
            InitializeComponent();
            tileChooser1.ChooserOrientation = Orientation.Horizontal;
            tileChooser1.Width = 253;
        }

        public static bool ShowFor(RandomBrush mb)
        {
            RandomBrushWizard rbw = new RandomBrushWizard();
            rbw.brush = mb;
            rbw.tileChooser1.Set = MainForm.Instance.MainView.Chooser.Set;
            rbw.textBox1.Text = mb.Name;
            rbw.ShowDialog(MainForm.Instance);
            return rbw.ok;
        }

        private void btnAccept_Click_1(object sender, EventArgs e)
        {
            brush.Name = textBox1.Text;
            ok = true;

            brush.Tiles.Clear();
            for (int y = 0; y < 5; ++y)
            {
                for (int x = 0; x < 8; ++x)
                {
                    Tile t = mapView1.Map.GetTileAt(x, y);
                    if (t != null) brush.Tiles.Add(t);
                }
            }

            this.Close();
        }
    }
}
